From: Keir Fraser Date: Sat, 27 Jun 2009 08:55:42 +0000 (+0100) Subject: xend: pass-through: Add key to pci device dictionary X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~13677^2~9 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=437cbbf3fb7c7ad2f13cdb29ceb92f63b1dc20c7;p=xen.git xend: pass-through: Add key to pci device dictionary This will be used to identify the functions belonging to a multi-function device. Cc: Dexuan Cui Cc: Masaki Kanno Signed-off-by: Simon Horman --- diff --git a/tools/python/xen/util/pci.py b/tools/python/xen/util/pci.py index b612489092..6975d9263d 100644 --- a/tools/python/xen/util/pci.py +++ b/tools/python/xen/util/pci.py @@ -277,7 +277,7 @@ def parse_pci_name_extended(pci_dev_str): template['domain'] = "0x%04x" % domain template['bus'] = "0x%02x" % int(pci_dev_info['bus'], 16) template['slot'] = "0x%02x" % int(pci_dev_info['slot'], 16) - template['func'] = "0x%x" % int(pci_dev_info['func'], 16) + template['key'] = pci_dev_str if pci_dev_info['opts'] != '': template['opts'] = split_pci_opts(pci_dev_info['opts']) check_pci_opts(template['opts']) @@ -290,6 +290,7 @@ def parse_pci_name_extended(pci_dev_str): pci_dev_info['func']) for func in func_list: pci_dev = template.copy() + pci_dev['func'] = "0x%x" % func if len(func_list) == 1: # For single-function devices vfunc must be 0 diff --git a/tools/python/xen/xend/XendConfig.py b/tools/python/xen/xend/XendConfig.py index 6e5f7f0693..4f26092f5d 100644 --- a/tools/python/xen/xend/XendConfig.py +++ b/tools/python/xen/xend/XendConfig.py @@ -1249,7 +1249,8 @@ class XendConfig(dict): dpci_record = { 'VM': self['uuid'], 'PPCI': ppci_uuid, - 'hotplug_slot': pci_dev.get('vslot', '0x%02x' % AUTO_PHP_SLOT) + 'hotplug_slot': pci_dev.get('vslot', '0x%02x' % AUTO_PHP_SLOT), + 'key': pci_dev['key'] } dpci_opts = pci_dev.get('opts') diff --git a/tools/python/xen/xend/XendDPCI.py b/tools/python/xen/xend/XendDPCI.py index 24fc6b23fe..e7507f0a40 100644 --- a/tools/python/xen/xend/XendDPCI.py +++ b/tools/python/xen/xend/XendDPCI.py @@ -42,6 +42,7 @@ class XendDPCI(XendBase): 'VM', 'PPCI', 'hotplug_slot', + 'key', 'options'] return XendBase.getAttrRO() + attrRO @@ -52,7 +53,8 @@ class XendDPCI(XendBase): def getAttrInst(self): attrInst = ['VM', 'PPCI', - 'hotplug_slot'] + 'hotplug_slot', + 'key'] return XendBase.getAttrInst() + attrInst def getMethods(self): @@ -120,6 +122,7 @@ class XendDPCI(XendBase): self.VM = record['VM'] self.PPCI = record['PPCI'] self.hotplug_slot = int(record['hotplug_slot'], 16) + self.key = record['key'] if 'options' in record.keys(): self.options = record['options'] @@ -155,5 +158,8 @@ class XendDPCI(XendBase): def get_hotplug_slot(self): return "%d" % self.hotplug_slot + def get_key(self): + return self.key + def get_options(self): return self.options diff --git a/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py index b22aeb80fb..b24392453c 100644 --- a/tools/python/xen/xend/XendDomainInfo.py +++ b/tools/python/xen/xend/XendDomainInfo.py @@ -3733,6 +3733,7 @@ class XendDomainInfo: ['slot', '0x%02x' % ppci.get_slot()], ['func', '0x%1x' % ppci.get_func()], ['vslot', '0x%02x' % xenapi_pci.get('hotplug_slot')], + ['key', xenapi_pci['key']], ['uuid', dpci_uuid]] dev_sxp = sxp.merge(dev_sxp, opts_sxp) diff --git a/tools/python/xen/xend/server/pciif.py b/tools/python/xen/xend/server/pciif.py index eed25470a1..38e7cb696b 100644 --- a/tools/python/xen/xend/server/pciif.py +++ b/tools/python/xen/xend/server/pciif.py @@ -83,6 +83,7 @@ class PciController(DevController): back['dev-%i' % pcidevid] = "%04x:%02x:%02x.%01x" % \ (domain, bus, slot, func) back['uuid-%i' % pcidevid] = pci_config.get('uuid', '') + back['key-%i' % pcidevid] = pci_config.get('key', '') back['vslot-%i' % pcidevid] = "%02x" % vslot pcidevid += 1 @@ -113,6 +114,7 @@ class PciController(DevController): dev = back['dev-%i' % i] state = states[i] uuid = back['uuid-%i' %i] + key = back['key-%i' %i] opts = '' if 'opts-%i' % i in back: opts = back['opts-%i' % i] @@ -135,6 +137,7 @@ class PciController(DevController): self.writeBackend(devid, 'state-%i' % devno, str(xenbusState['Initialising'])) self.writeBackend(devid, 'uuid-%i' % devno, uuid) + self.writeBackend(devid, 'key-%i' % devno, key) if len(opts) > 0: self.writeBackend(devid, 'opts-%i' % devno, opts) if back.has_key('vslot-%i' % i): @@ -173,6 +176,7 @@ class PciController(DevController): # Per device uuid info pci_dev['uuid'] = self.readBackend(devid, 'uuid-%d' % i) + pci_dev['key'] = self.readBackend(devid, 'key-%d' % i) pci_dev['vslot'] = '0x%s' % self.readBackend(devid, 'vslot-%d' % i) #append opts info @@ -500,7 +504,7 @@ class PciController(DevController): # In HVM case, I/O resources are disabled in ioemu. self.cleanupOneDevice(pci_dev) # Remove xenstore nodes. - list = ['dev', 'vdev', 'state', 'uuid', 'vslot'] + list = ['dev', 'vdev', 'state', 'uuid', 'vslot', 'key'] if self.readBackend(devid, 'opts-%i' % i) is not None: list.append('opts') for key in list: @@ -510,7 +514,7 @@ class PciController(DevController): if new_num_devs == i + 1: continue - list = ['dev', 'vdev', 'state', 'uuid', 'opts', 'vslot'] + list = ['dev', 'vdev', 'state', 'uuid', 'opts', 'vslot', 'key'] for key in list: tmp = self.readBackend(devid, '%s-%i' % (key, i)) if tmp is None: diff --git a/tools/python/xen/xm/create.dtd b/tools/python/xen/xm/create.dtd index 06e7176b07..7589292206 100644 --- a/tools/python/xen/xm/create.dtd +++ b/tools/python/xen/xm/create.dtd @@ -90,7 +90,8 @@ slot CDATA #REQUIRED func CDATA #REQUIRED opts_str CDATA #IMPLIED - vslot CDATA #IMPLIED> + vslot CDATA #IMPLIED + key CDATA #IMPLIED> 0: pci_dev['opts'] = opts return pci_dev diff --git a/tools/python/xen/xm/main.py b/tools/python/xen/xm/main.py index 0d86ae018d..b6775cd6df 100644 --- a/tools/python/xen/xm/main.py +++ b/tools/python/xen/xm/main.py @@ -2186,7 +2186,8 @@ def attached_pci_dict_bin(dom): 'bus': int(ppci_record['bus']), 'slot': int(ppci_record['slot']), 'func': int(ppci_record['func']), - 'vslot': int(server.xenapi.DPCI.get_hotplug_slot(dpci_ref)) + 'vslot': int(server.xenapi.DPCI.get_hotplug_slot(dpci_ref)), + 'key': server.xenapi.DPCI.get_key(dpci_ref) } devs.append(dev) @@ -2197,7 +2198,8 @@ def attached_pci_dict_bin(dom): 'bus': int(x['bus'], 16), 'slot': int(x['slot'], 16), 'func': int(x['func'], 16), - 'vslot': int(x['vslot'], 16) + 'vslot': int(x['vslot'], 16), + 'key': x['key'] } devs.append(dev) @@ -2543,6 +2545,7 @@ def xm_pci_attach(args): slot = int(sxp.child_value(pci_dev, 'slot'), 16) func = int(sxp.child_value(pci_dev, 'func'), 16) vslot = int(sxp.child_value(pci_dev, 'vslot'), 16) + key = sxp.child_value(pci_dev, 'key') name = "%04x:%02x:%02x.%01x" % (domain, bus, slot, func) target_ref = None @@ -2557,7 +2560,8 @@ def xm_pci_attach(args): "VM": get_single_vm(dom), "PPCI": target_ref, "hotplug_slot": vslot, - "options": dict(config_pci_opts) + "options": dict(config_pci_opts), + "key": key } server.xenapi.DPCI.create(dpci_record) diff --git a/tools/python/xen/xm/xenapi_create.py b/tools/python/xen/xm/xenapi_create.py index 790a6149dd..8e05e3632f 100644 --- a/tools/python/xen/xm/xenapi_create.py +++ b/tools/python/xen/xm/xenapi_create.py @@ -543,7 +543,9 @@ class xenapi_create: int(pci.attributes["vslot"].value, 16), "options": get_child_nodes_as_dict(pci, - "pci_opt", "key", "value") + "pci_opt", "key", "value"), + "key": + pci.attributes["key"].value } return server.xenapi.DPCI.create(dpci_record) @@ -946,6 +948,8 @@ class sxp2xml: = get_child_by_name(dev_sxp, "func", "0") pci.attributes["vslot"] \ = get_child_by_name(dev_sxp, "vslot", "0") + pci.attributes["key"] \ + = get_child_by_name(dev_sxp, "key", "0") for opt in pci_opts_list_from_sxp(dev_sxp): pci_opt = document.createElement("pci_opt") pci_opt.attributes["key"] = opt[0]